home *** CD-ROM | disk | FTP | other *** search
/ 1,000 Game Manuals / 1000gamemanuals.iso / Atari 2600 / Basic Programming.txt < prev    next >
Text File  |  1997-03-16  |  27KB  |  819 lines

  1. The BASIC Programming manual is 24 pages, plus 2 keyboard overlays.
  2.  
  3. Transcriber's note: This manual contains numerous uses of a left-arrow
  4. symbol. Because there is no ASCII equivalent, I will use an exclamation
  5. point (!) to represent the left-arrow. Also, wherever the division sign is
  6. used (a - with dots over and below it), I will use a /.
  7.  
  8. BASIC
  9. PROGRAMMING
  10. GAME PROGRAM(tm)
  11. INSTRUCTIONS
  12.  
  13. Model CX2620
  14.  
  15. ATARI(R)
  16. A Warner Communications Company
  17.  
  18. ATARI, INC., Consumer Division
  19. 1195 Borregas Ave., Sunnyvale, CA 94086
  20.  
  21. (C) 1979 ATARI, INC.
  22.  
  23. BASIC PROGRAMMING
  24.  
  25. INTRODUCTION
  26.  
  27. BASIC PROGRAMMING is an instructional tool designed to teach you the
  28. fundamental steps of computer programming. BASIC is an acronym for
  29. Beginners All-purpose Symbolic Instruction Code. It was originated to that
  30. people could easily learn to "write" computer programs.
  31.  
  32. Computer programs are simply a series of instructions. The programs control
  33. the flow of information within the computer. BASIC PROGRAMMING allows you
  34. to give the Video Computer System(tm) the instructions it needs to carry
  35. out some simple tasks.
  36.  
  37. Keep in mind that BASIC PROGRAMMING has a limited amount of memory in
  38. comparison to more sophisticated computer systems. It is, however, an
  39. excellent instructional device for learning the essentials of computer
  40. programming.
  41.  
  42. NOTE: Turn the console off when inserting or removing a Game Program(tm).
  43. This will protect the electronic components and prolong the life of your
  44. Atari(R) Video Computer System.
  45.  
  46. This Game Program may cause some television screens to "roll" slightly. If
  47. this occurs, adjustment of the VERTICAL HOLD may be necessary.
  48.  
  49. KEYBOARD CONTROLLERS
  50.  
  51. Use your Keyboard Controllers with this ATARI(R) Game Program.(tm) Be sure
  52. the Controllers are firmly plugged into the LEFT and RIGHT CONTROLLER jacks
  53. at the rear of your ATARI Video Computer System.(tm)
  54.  
  55. To connect the two controllers, slide the tongue of the left controller
  56. into the groove on the right controller. The two Keyboard Controllers,
  57. locked together, form a 24-key Keyboard used to enter your program and to
  58. control the display on your television screen.
  59.  
  60. (Transcriber's note: The above paragraph is accompanied by a line drawing
  61. of the keyboard controllers partially fitted together. Below that is a
  62. reproduction of the keyboard labels. See the end of this manual for a
  63. transcription of the labels.)
  64.  
  65. Remove the Keyboard Controller labels from the envelope. Place the label
  66. marked LEFT over the Keyboard plugged into the LEFT CONTROLLER jack at the
  67. rear of your computer console. Place the label marked RIGHT over the
  68. Keyboard plugged into the RIGHT CONTROLLER jack at the rear of your
  69. computer console.
  70.  
  71. DISPLAY REGIONS
  72.  
  73. The display is divided into six regions:
  74.  
  75. 1. The PROGRAM region is used to give the computer your instructions.
  76.  
  77. 2. The STACK region will give you the temporary results of your program as
  78. the computer is running it.
  79.  
  80. 3. The VARIABLES region will give you the value of each variable item in
  81. your program as the computer is running it.
  82.  
  83. 4. The OUTPUT region will show you the output being produced as your
  84. program is being run.
  85.  
  86. 5. The STATUS region shows you the amount of memory available at any time
  87. for your program. This region will also give you the speed of execution of
  88. your program.
  89.  
  90. 6. The GRAPHICS region has two colored squares which can be moved around
  91. under your program control.
  92.  
  93. Before beginning your program, place the left difficulty switch in the b
  94. position. This will show you where each region is on your display. When the
  95. left difficulty switch is place in the a position, the titles of each
  96. region will disappear from the display and the GRAPHICS region will come
  97. into view.
  98.  
  99. The right difficulty switch has no function in this Game Program.
  100.  
  101. Illustration 1 (B setting):
  102.  
  103. STATUS
  104. SYMBOLS=63
  105. SPEED=30
  106.  
  107. PROGRAM
  108. 1
  109.  
  110. STACK
  111.  
  112. VARIABLES
  113.  
  114. OUTPUT
  115.  
  116. Illustration 2 (A setting):
  117.  
  118. SYMBOLS=63
  119. SPEED=30
  120.  
  121. 1
  122.  
  123. THE CURSOR
  124.  
  125. Place the left difficulty switch into the b position and turn your console
  126. off and then on again. In the PROGRAM region there is a white rectangle.
  127. This is the cursor. Locate the "shift control key" at the center of the
  128. bottom row on the left controller. Push this key four times. The color of
  129. the cursor will change from white to red, from red to blue, from blue to
  130. green, and from green to white again.
  131.  
  132. The cursor is used to input your program. Each of the four colors on the
  133. shift key corresponds to the colored commands or inputs on your Keyboard.
  134. The white mode is used to give your computer commands, the other modes are
  135. used to insert symbols into your program.
  136.  
  137. Moving the Cursor from Region to Region
  138.  
  139. Make sure the left difficulty switch is in the b position and turn your
  140. console unit off and then on again. Push the FORWARD key and the cursor
  141. will move from PROGRAM to STACK. Press the FORWARD key again and the cursor
  142. will move from STACK to VARIABLES. Push the key again and the cursor will
  143. move from VARIABLES to OUTPUT.
  144.  
  145. By pushing the BACKWARD key you can move the cursor back to the PROGRAM
  146. region. The FORWARD and BACKWARD keys can be pushed once for each region or
  147. held down.
  148.  
  149. Now place the left difficulty switch into the a position. The titles of
  150. each region will disappear and a portion of the GRAPHICS region will
  151. appear. Step the cursor through each of the regions again. Notice that the
  152. cursor will not move into the GRAPHICS region.
  153.  
  154. Removing the Regions from the Display
  155.  
  156. Place the left difficulty switch into the b position again and turn your
  157. console unit off and then on. On the left side of the Keyboard are a series
  158. of commands (white mode) that correspond with each of the regions: STATUS,
  159. PROGRAM, STACK, VARIABLES, OUTPUT, and GRAPHICS. Let's start with the
  160. STATUS region. Push the STATUS key once and the STATUS region will
  161. disappear from the screen and the PROGRAM region will move to the top of
  162. the display.
  163.  
  164. Push the PROGRAM key and the PROGRAM region will disappear and the STACK
  165. region will move to the top of the display. Push the STACK key and the
  166. STACK region will disappear and the VARIABLES region will move to the top
  167. of the display. Push the VARIABLES key and the VARIABLES region will
  168. disappear causing the OUTPUT region to move to the top of the display.
  169.  
  170. Remove the OUTPUT region by pushing the OUTPUT key. This will also cause
  171. the GRAPHICS region to be fully visible on the display. Push the GRAPHICS
  172. key to remove the GRAPHICS region. Your display should show no regions.
  173.  
  174. Now push the STACK key. The STACK region will reappear on your display.
  175. Remove the STACK region, and bring up the OUTPUT and VARIABLES regions. You
  176. may display or remove any region with the left difficulty switch in either
  177. the a or b position.
  178.  
  179. It is important to note that whether or not the various regions are
  180. displayed has no effect on the execution of a program.
  181.  
  182. RUNNING A PROGRAM
  183.  
  184. Let's do a simple program. Make sure the left difficulty switch is in the b
  185. position and turn your console unit off and then on again. (Another way to
  186. erase a program and reset all values is to depress the game select switch.
  187. Pushing the game reset switch erases all values and returns a program to
  188. its beginning without erasing the program.)
  189.  
  190. Remove the STACK, VARIABLES, OUTPUT, and GRAPHICS regions from the display.
  191. The cursor will be in the white mode and to the right of the number 1 in
  192. the PROGRAM region. Change the cursor to the blue mode and push the A key.
  193. The letter A will appear on the display next to the 1. (Each line is
  194. numbered, making it possible to see where one line ends and the next one
  195. begins.) Now change the cursor to the red mode and push the ! key. A small
  196. arrow will appear next to the A. Now go back to blue and input B. Changing
  197. the cursor to red, input + and the number 2. Now go back to the white mode
  198. and input New Line. You must always be in the white mode in order to start
  199. a new line in your program.
  200.  
  201. Your display should look like this.
  202.  
  203. STATUS
  204. SYMBOLS=57
  205. SPEED=30
  206. PROGRAM
  207. 1 A!B=2
  208. 2
  209.  
  210. (Transcriber's note: remember that I'm using ! to indicate the left arrow
  211. symbol)
  212.  
  213. If you make an error in entering your program, it can be erased using the
  214. ERASE key. Notice that the ERASE key is not color coded. It can be used
  215. when the shift key is in any color mode.
  216.  
  217. Using the line that you have just entered into your program, let's do an
  218. exercise. Push the ERASE key once. The cursor will move from line 2
  219. directly to the right of the 2 on line 1. Push the ERASE key again and the
  220. 2 will be erased from the program. Now enter 1, using the red mode. Change
  221. the cursor to the white mode and using the BACKWARD key, move the cursor
  222. until it is directly to the right of the B in the program. Push the ERASE
  223. key and the letter will be removed from the program. Now replace it with A
  224. (blue mode). In the white mode, use the FORWARD key to move to the end of
  225. line 1 and input New Line.
  226.  
  227. Remember that the cursor should not be on the symbol to be erased but
  228. directly to the right of it. Your screen display will now look like this:
  229.  
  230. STATUS
  231. SYMBOLS=57
  232. SPEED=30
  233. PROGRAM
  234. 1 A!A+1
  235. 2
  236.  
  237. The cursor is directly to the right of the 2 in line 2. Now input PRINT
  238. using the green mode. Then, with the blue mode, input A and go to a New
  239. Line. Your display will look like this:
  240.  
  241. STATUS
  242. SYMBOLS=54
  243. SPEED=30
  244. PROGRAM
  245. 1 A!A+1
  246. 2 Print A
  247. 3
  248.  
  249. Now, with the cursor in the green mode, input GOTO, and then, in the red
  250. mode, input 1. Before we do anything else, let's look at the display again.
  251.  
  252. STATUS
  253. SYMBOLS=52
  254. SPEED=30
  255. PROGRAM
  256. 1 A!A+1
  257. 2 Print A
  258. 3 Goto 1
  259.  
  260. Notice that the STATUS region shows we have 52 "bytes" or symbols of memory
  261. remaining. The speed is set at 30 (SPEED=30). Put the cursor into the white
  262. mode and depress the SLOWER key. Notice that every time you depress this
  263. key the speed decreases. Depress the FASTER key and the SPEED will
  264. increase.
  265.  
  266. Before we start the program, input SPEED=1. Now depress the STACK key.
  267. Press the RUN/HALT key twice and the program will begin. You can watch the
  268. computer work each part of the program.
  269.  
  270. STATUS
  271. SYMBOLS=41
  272. SPEED=1
  273. PROGRAM
  274. 1 A!A+1
  275. 2 Print A
  276. 3 Goto 1
  277. STACK
  278. A!3
  279.  
  280. To stop the program press RUN/HALT. As noted before, pressing the game
  281. reset switch erases all values in your program (without erasing the program
  282. itself), and returns the program to its beginning.
  283.  
  284. Let's analyze the program step by step as the computer runs through it.
  285. Change SPEED to 60. With the cursor in the white mode depress the STEP key.
  286. This will take each part of the program one step at a time, each time it is
  287. pressed.
  288.  
  289. In line 1 the program reads A!A+1. The computer reads this as A "becomes"
  290. A+1. Watch the STACK region as you step through line 1. In line 2, you have
  291. told the computer in Print A. This means you want the computer to print the
  292. value of A (as determined by line 1) in the OUTPUT region.
  293.  
  294. We'll see how that works later. Line 3 tells the computer to Goto 1. The
  295. computer is to return to line 1 and find a new value for A. Each time the
  296. program is run through it will find a new value for A, print that value,
  297. and then return to line 1. The computer will continue to run through the
  298. program in this manner until all the "memory" is used. The amount of
  299. remaining memory is shown in the SYMBOLS area of the STATUS region.
  300.  
  301. Bring up the VARIABLES region on the display. Change the SPEED to 1 and
  302. clear the values of the program by pressing the game reset switch. Push the
  303. RUN/HALT key and watch as the computer runs through the program. The
  304. computer will show you the current value of A at each step of your program.
  305. Your screen display will look like this:
  306.  
  307. STATUS
  308. SYMBOLS=27
  309. SPEED=1
  310. PROGRAM
  311. 1 A!A+1
  312. 2 Print A
  313. 3 Goto 1
  314. STACK
  315. Print 11
  316. VARIABLES
  317. A is 11
  318.  
  319. Stop the program and clear the values (game reset). Remove the VARIABLES
  320. region and bring up the OUTPUT region on the display. Change SPEED to 60.
  321. The display will now look like this:
  322.  
  323. STATUS
  324. SYMBOLS=52
  325. SPEED 60
  326. PROGRAM
  327. 1 A!A+1
  328. 2 Print A
  329. 3 Goto 1
  330. STACK
  331.  
  332. OUTPUT
  333.  
  334. Press the RUN/HALT key and start the program. In line 2, the computer is
  335. instructed to PRINT A. When it reaches this command, it will bring the
  336. current value of A in the OUTPUT region. Watch the SYMBOLS area of the
  337. STATUS region. Even though 1 shows in the OUTPUT region on your display,
  338. the computer is still printing the changing value of A. Put the left
  339. difficulty switch in the a position. Your display will now look something
  340. like this:
  341.  
  342. SYMBOLS=2
  343. SPEED=60
  344. 1 A!A+1
  345. 2 Print A
  346. 3 Goto1
  347.  
  348. Print12
  349.  
  350. 1
  351. 2
  352. 3
  353. 4
  354.  
  355. How can we show more of the OUTPUT region on the display? Remove the
  356. STATUS, PROGRAM, and STACK regions from the display. Your display will look
  357. like this:
  358.  
  359. 1
  360. 2
  361. 3
  362. 4
  363. 5
  364. 6
  365. 7
  366. 8
  367. 9
  368. 10
  369. 11
  370.  
  371. Suppose we don't want to overload the OUTPUT region of the program? Stop
  372. the program and erase the values with the game reset switch. Remove the
  373. OUTPUT region from the display and bring up the PROGRAM region. Using the
  374. FORWARD key, move the cursor to the end of line 1, so that your display
  375. looks like this:
  376.  
  377. 1 A!A+1
  378. 2 Print A
  379. 3 Goto 1
  380.  
  381. Now depress the NEW LINE key. We will insert a new command here. Input
  382. CLEAR (green mode). Your display will look like this:
  383.  
  384. 1 A!A+1
  385. 2 Clear
  386. 3 Print A
  387. 4 Goto 1
  388.  
  389. Bring up STACK, VARIABLES and OUTPUT. Leave the left difficulty switch in
  390. the a position and start the program. As the program passes line 2 CLEAR it
  391. erases the value of A in the OUTPUT region and the prints the next value of
  392. A in line 3.
  393.  
  394. BASIC PROGRAMMING can only work with two-digit numbers, so as it reaches 99
  395. it will "wraparound" and begin again showing A's value to be 0.
  396.  
  397. USING THE NOTE FUNCTION
  398.  
  399. Each time the program stores a number into NOTE (red mode), a note from the
  400. musical scale will be sounded by your television speaker.
  401.  
  402. Let's do some programs to demonstrate. If you have any programs in your
  403. Video Computer System, depress the game select switch on the console unit.
  404.  
  405. Input the following:
  406.  
  407. 1 Note!Note+1
  408. 2 Goto 1
  409.  
  410. Now start the program. Slow the program down and watch it being worked in
  411. the STACK region. Also notice that the program will print the current value
  412. of NOTE in the VARIABLES region.
  413.  
  414. Stop the program and insert a new line 2 (in the white mode, move the
  415. cursor to the end of line 1 and press NEW LINE. The previous line 2 will
  416. become line 3).
  417.  
  418. 2 If Note>6 Then Note!0
  419.  
  420. Your display will look like this:
  421. (IF STACK and VARIABLES regions are removed.)
  422.  
  423. 1 Note!Note+1
  424. 2 If Note>6 Then Note
  425. !0
  426. 3 Goto 1
  427.  
  428. With the IF and THEN commands, we are instructing the program that IF
  429. something happens, THEN it is to do something else. In this case, IF Note
  430. is more than 6, THEN Note is to be changed to 0. Start the program and
  431. watch it being worked in the STACK region. Notice that as the value of Note
  432. reaches 7, it becomes more then (>) 6 and the program changes the value to
  433. 0.
  434.  
  435. Let's do another program to achieve the same result in a different way.
  436. Input the following:
  437.  
  438. 1 Note!C
  439. 2 C!C+1
  440. 3 If C>7 Then C!0
  441. 4 Goto 1
  442.  
  443. Run the program. Notice that the same results are achieved, except that the
  444. notes are spaced evenly. If you want the program to give you the value of C
  445. in the OUTPUT region, input Print C and Clear as instructions anywhere in
  446. the program. To cut down on the flicker in the OUTPUT region as the program
  447. is giving you the value, insert a comma, (green mode) after the value in
  448. the Print line, Print C.
  449.  
  450. You may use any letter of the alphabet for the variable in your programs.
  451. The following program has all the key functions we have learned so far and
  452. uses nearly all the available "memory" in the computer. After entering this
  453. program, remove the program from the display, bring up the STATUS, STACK,
  454. and OUTPUT regions, and run the program.
  455.  
  456. In this program we have given two IF/THEN commands. If the conditions set
  457. up in the first command are not met (line 4) the computer will move to the
  458. next line (line 5). Given enough memory, there can be several commands
  459. between any two IF/THEN commands.
  460.  
  461. In some cases we can put two commands on one line, as in line 1 and line 2
  462. in the above program. In this way we can save some of the memory for later
  463. in the program.
  464.  
  465. USING THE KEY AND PRINT FUNCTIONS
  466.  
  467. The KEY function (red mode) is used to input a variable while the program
  468. is running. The program will evaluate KEY and replace it with a number that
  469. you input from the right side of the Keyboard. If no number is inputted,
  470. then the program will read KEY as 0.
  471.  
  472. Here's a simple program using the KEY function:
  473.  
  474. SYMBOLS=50
  475. SPEED=30
  476.  
  477. 1 If Key>0 Then Note!
  478. Key
  479. 2 Goto 1
  480.  
  481. Start the program and push some of the keys on the right side of the
  482. Keyboard. With practice you may be able to play a tune.
  483.  
  484. The KEY function can also be used for programming in the GRAPHICS region as
  485. we will see later.
  486.  
  487. Try this program using the KEY, NOTE, and PRINT functions:
  488.  
  489. SYMBOLS=34
  490. SPEED=30
  491. 1 A!Key
  492. 2 Note!A Print A
  493. 3 If A=0 Then Clear
  494. 4 Goto 1
  495.  
  496. 9
  497.  
  498. Watch this program in the OUTPUT region. Notice that as you input a number
  499. from the right side of the Keyboard the program will play that tone and
  500. display that number in the OUTPUT region.
  501.  
  502. Now let's make a minor modification in the program. In line 2, insert a
  503. comma (,) after Print A and start the program. By inserting the comma here
  504. you have told the program that you want as many of the variables printed on
  505. one line as possible.
  506.  
  507. USING THE PRINT FUNCTION
  508.  
  509. As we showed in earlier programs, you can use the PRINT function to
  510. instruct the program to print the value of a variable in the OUTPUT region.
  511. The PRINT function can also be used to instruct the program to print words
  512. on the display. Words to be displayed must be enclosed in quotation marks
  513. ("). Set the SPEED at 8 and input the following program:
  514.  
  515. 1 Print "A"
  516. 2 Print "IS"
  517. 3 Print A
  518. 4 A!A+1
  519. 5 Clear
  520. 6 Goto 1
  521.  
  522. Now run the program and watch the OUTPUT region. The program prints the
  523. words you have inputted, but they are "stacked."
  524.  
  525. Let's change the program slightly by inputting a comma (,) at the end of
  526. line 1 and line 2. The program now looks like this:
  527.  
  528. 1 Print "A"
  529. 2 Print "IS"
  530. 3 Print A
  531. 4 A!A+1
  532. 5 Clear
  533. 6 Goto 1
  534.  
  535. A IS 12
  536.  
  537. The comma (,) in line 1 has instructed the program that whatever is on line
  538. 2 is to be displayed in the OUTPUT region on the same line as the
  539. instruction on line 1. The comma in line 2 has instructed the program that
  540. the line 3 instruction is to follow line 2. These instructions can be
  541. shortened by changing the program to read:
  542.  
  543. 1 Print "A","IS"
  544. ,A
  545. 2 A!A+1
  546. 3 Clear
  547. 4 Goto 1
  548.  
  549. A IS 15
  550.  
  551. The program can be further shortened:
  552.  
  553. 1 Print "A IS", A
  554. 2 A!A+1
  555. 3 Clear
  556. 4 Goto 1
  557.  
  558. A IS 18
  559.  
  560. Writing the program in this fashion will also save some memory.
  561.  
  562. USING THE GRAPHICS REGION
  563.  
  564. The GRAPHICS region is the blue rectangular field on your television
  565. screen. At first glance it appears to contain one red square in the upper
  566. left corner. The red square actually covers a white square and both may be
  567. moved independently on the field under your program control.
  568.  
  569. To move the squares you must change their coordinates. The red square is
  570. object number 1. Its horizontal coordinate is represented on the Keyboard
  571. by Hor 1 and its vertical coordinate by Ver 1. Hor 2 and Ver 2 are the
  572. coordinates of object number 2, the white square.
  573.  
  574. Both objects or squares start out in the upper left corner of the blue
  575. field, with only the red square showing. The upper left corner is the zero
  576. (0) position or origin. When the variables Hor 1, Ver 1, Hor 2 and Ver 2
  577. are not defined (given values) they have values of 0 (therefore causing the
  578. squares to remain in the upper left corner position).
  579.  
  580. When a coordinate is assigned a value other than 0, (e.g. Hor 1!10), the
  581. object involved will jump to the corresponding position on the blue field
  582. when the program is executed.
  583.  
  584. Input the following program:
  585.  
  586. 1 Hor 1!Hor 1+1
  587. 2 Goto 1
  588. Hor 1 is 17
  589.  
  590. This program will move the red square to the right, one horizontal space at
  591. a time. Run this program and you will see the red square moving slowly to
  592. the right. Check the VARIABLES region and you will see the value of Hor 1
  593. increasing. It will increase until it reaches 99, the largest number
  594. allowed, and then drop back to 0. When Hor 1 reaches 99, the red square
  595. will have reached the far right side of the blue field. At this point, the
  596. red square "wraps around" and starts again from the far left side of the
  597. field, with Hor 1 at 0.
  598.  
  599. The horizontal coordinates (Hor 1 and Hor 2) then, range from 0 to 99. The
  600. vertical coordinates (Ver 1 and Ver 2) also range from 0 to 99, with 0
  601. being the position at the top of the blue field, and 99 being the position
  602. at the bottom.
  603.  
  604. Input the following program:
  605.  
  606. 1 Hor 1!Hor 1+6
  607. 2 Ver 1!Ver 1+8
  608. 3 Hor 2!Hor 2+4
  609. 4 Ver 2!Ver 2+4
  610. 5 If Hit Then Note!2
  611. Else Note!7
  612. 6 Goto 1
  613.  
  614. Remove the program from the screen and make sure the GRAPHICS region is
  615. fully visible. Set the speed at 60 and run the program. This program shows
  616. you one way to move the squares on the field. It also reveals how the HIT
  617. and ELSE functions may be put to use.
  618.  
  619. In line 5 the program is instructing the computer to sound the 2 note IF
  620. the squares HIT, which they do periodically. To HIT means the squares must
  621. occupy the same coordinates. Otherwise (ELSE) the computer is instructed to
  622. play the 7 note, which it will do until the squares hit.
  623.  
  624. (Remove ELSE NOTE!7 from line 5 and note 2 will be played when the squares
  625. hit and no other note will be sounded.)
  626.  
  627. USING THE MOD FUNCTION
  628.  
  629. Mod is an arithmetic operator, much like the division operator (/). BASIC
  630. PROGRAMMING employs integer division, which means it works with whole
  631. numbers only, and leaves no remainder. For example, what is 14/5? You might
  632. say 2 and 4/5, or 2, remainder 4. In BASIC PROGRAMMING 14/5 is 2. Although
  633. 5 divides into 14 twice (making 10), with 4 left over, BASIC uses whole
  634. numbers only, so the answer it gives you is 2.
  635.  
  636. The computer will give you the same answer for 12/4 as it will for 13/4.
  637. The answer in both instances is 3, since 4 will divide into both 12 and 13,
  638. 3 whole times. The computer will not recognize the remainder of 1 in the
  639. case of 13/4.
  640.  
  641. Now for the Mod function. Mod gets the remainder left over after dividing
  642. the first number into the second number. So, 14 Mod 5 is 4. Five divides
  643. into 14 twice (making 10) with 4 left over. Mod gets the remainder left
  644. over, therefore Mod is 4.
  645.  
  646. What is 13 Mod 4? The answer is 1 since 1 is left over after dividing 4
  647. into 13 (which makes 12). How about 12 Mod 4? In this case, Mod is 0 since
  648. 4 divides into 12 evenly with nothing or 0 remaining.
  649.  
  650. Normally, dividing by 0 is undefined, mathematically speaking. In BASIC
  651. PROGRAMMING, dividing by 0 just gives a result of 0, so that 5/0 is 0.
  652.  
  653. Operator Priorities
  654.  
  655. In an equation, the arithmetic operators (+, -, x, /, Mod, etc.) are worked
  656. out in order of an established priority. BASIC PROGRAMMING uses the
  657. following operator priority guide:
  658.  
  659. 1. x / (Highest)
  660. 2. + -
  661. 3. Mod
  662. 4. =
  663. 5. ! (Lowest)
  664.  
  665. Using Parenthesis
  666.  
  667. Using parenthesis (green mode, left side of Keyboard), gives priority to
  668. whichever numbers the parenthesis surround when working out an equation.
  669.  
  670. For example, when working out the following equation:
  671.  
  672. A 5+3x2 Mod 7
  673.  
  674. the first step is: 3x2=6
  675. the second step is: 5+6=11
  676. the third step is: 11 Mod 7=4
  677. A=4
  678.  
  679. However, the same equation with parenthesis inserted, is worked out
  680. differently and gives a different answer for A.
  681.  
  682. A (5+3)x2 Mod 7
  683.  
  684. first step: 5+3=8
  685. second step: 8x2=16
  686. third step: 16 Mod 7=2
  687. A=2
  688.  
  689. SAMPLE PROGRAMS
  690.  
  691. Here are some sample programs. They will help you see the wide range of
  692. possibilities you have to work with. Remember to pay close attention to how
  693. a particular command (IF, THEN, HIT, ELSE, PRINT, KEY, etc.) affects a
  694. program. Remember too that a KEY command may depend on your input from the
  695. right side of the Keyboard for successful operation of the program.
  696.  
  697. Whenever a particular program confuses you, stop the program, reset it to
  698. the beginning, and STEP through it. By watching the program in the STACK
  699. region and seeing how the computer works out each step, you should be able
  700. to understand what is happening and why it is happening.
  701.  
  702. After running the programs and becoming familiar with the fundamentals of
  703. computer programming in general, you'll be well on your way toward writing
  704. some programs of your own.
  705.  
  706. Hit
  707.  
  708. 1 Clear Print Hit
  709. 2 Hor 2!Hor 2+1 Mod
  710. 3 3
  711. 4 Goto 1
  712.  
  713. Music
  714.  
  715. 1 Note!If Note>4
  716. Then Note-11 Else
  717. Note+1
  718. 2 Note!Note+2
  719. 3 Note!Note-2
  720. 4 Goto 1
  721.  
  722. 1 A!Key
  723. 2 If A>0 Then Note!A
  724. -1
  725. 3 Goto 1
  726.  
  727. 1 Note!Note+Key+
  728. 7
  729. 2 Goto 1
  730.  
  731. 1 A!A+1
  732. 2 Note!A
  733. 3 If (A Mod 2)=2 Then
  734. Note!0 Else Note!4
  735. 4 Goto 1
  736.  
  737. Clock-Like Program
  738.  
  739. When running the Clock program bring up the OUTPUT region only. The SPEED
  740. may be set at 30 or 60.
  741.  
  742. 1 Clear
  743. 2 A!A+1 Mod 60
  744. 3 If A=0 Then B!B+1
  745. Mod 60
  746. 4 Print B,A
  747. 5 Goto 1
  748.  
  749. Pong(R) Game
  750. (Ball & Paddle)
  751.  
  752. 1 Hor 1!Hor 1+Key
  753. 2 Hor 2!Hor 2+8
  754. 3 Ver 2!Ver 2-3
  755. 4 If Hit Then Ver 2!99
  756. ,Note!7
  757. 5 Goto 1
  758.  
  759. Pong(R) Game
  760. without sound
  761.  
  762. 1 Hor 2!Hor 2+Key
  763. 2 If Ver 1>90 Then
  764. Ver 1!88
  765. 3 If Hit Then Ver 1!9
  766. 4 Ver 1!Ver 1+If
  767. Ver 1 Mod 2 Then 8 Else
  768. 92
  769. 5 Hor 1!Hor 1+7
  770. 6 Goto 1
  771.  
  772. C011402-20 Rev. 2 Printed in USA
  773.  
  774. ---------------------------------------------------------------------------
  775. Keyboard labels
  776.  
  777. Each key (except the bottom 3 on the left controller) has either 3 or 4
  778. meanings, depending on what color the shift key is set for. For example,
  779. the top left key on the left controller is as follows:
  780.  
  781. STATUS
  782. + A IF
  783.  
  784. STATUS is printed in white, + in red, A in blue and IF in green. Please
  785. remember that ! means the left arrow and / means the divsion symbol.
  786.  
  787. LEFT CONTROLLER
  788.  
  789. STATUS    PROGRAM   STACK
  790.  
  791. + A IF    - B THEN  ! C ELSE
  792.  
  793. VARIABLES OUTPUT    GRAPHICS
  794.  
  795. X D GOTO  / E PRINT NOTE F "
  796.  
  797. STEP      SLOWER    FASTER
  798.  
  799. HOR1 G (  VER1 H )  KEY I ,
  800.  
  801. RUN/HALT  SHIFT     ERASE
  802.  
  803. RIGHT CONTROLLER
  804.  
  805. 1 J U     2 K V     3 L W
  806.  
  807. 4 M X     5 N Y     6 O Z
  808.  
  809. 7 P CLEAR 8 Q MOD   9 R HIT
  810.  
  811. BACKWARD  FORWARD   NEW LINE
  812.  
  813. HOR2 S =  VER2 T >  0 SPACE <
  814.  
  815. ---------------------------------------------------------------------------
  816. Document converted to html by gchance@ecst.csuchico.edu
  817. -------------------Atari 2600 Instructions Archive-------------------
  818. ---------------------------------------------------------------------------
  819.